import redis
import const

def get_pool():
    selection = 'redis'
    host = const.CFG.get(selection, 'host')
    port = const.CFG.get(selection, 'port')
    db = const.CFG.get(selection, 'db')
    return redis.ConnectionPool(max_connections=300, host=host, port=port, db=db, decode_responses=True)


def get_connect():
    return redis.Redis(connection_pool=get_pool())

def convert_to_dict(res):
    res = res.replace('false', 'False')
    res = res.replace('true', 'True')
    res_dict = eval(res)
    return res_dict

